package com.example.demo.service;

import com.example.demo.bean.*;
import com.example.demo.repository.FileRepository;
import com.example.demo.repository.StudentFileRepository;
import com.example.demo.repository.TimetableRepository;
import com.example.demo.repository.UserTimetableZJRepository;
import com.example.demo.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;

@Transactional
@Service
public class FileService {

    @Autowired
    FileRepository fileRepository;

    @Autowired
    StudentFileRepository studentFileRepository;

    public FileBean addFile(FileBean fileBean){
        return fileRepository.save(fileBean);
    }

    public StudentFileBean addStuFile(StudentFileBean studentFileBean){
        return studentFileRepository.save(studentFileBean);
    }

    public StudentFileBean addStudentFile(StudentFileBean fileBean){
        return studentFileRepository.save(fileBean);
    }

    public List<Map<String, Object>> findTask(String timetable_id){
        List<Map<String, Object>> list = fileRepository.findTaskBean(timetable_id);
        return list;
    }

    public List<Map<String, Object>> findStudentTask(String timetable_id){
        List<Map<String, Object>> list = studentFileRepository.findStudentTaskBean(timetable_id);
        return list;
    }

    public StudentFileBean findByObjId(String objid){
        return studentFileRepository.findByObjId(objid);
    }

    public int findTimetableCount(String timetable_id){
        return studentFileRepository.findTimetableCountBean(timetable_id);
    }
}
